let Home = {
    baseUrl: 'http://81.71.65.4:3003',
    renderOrder(token) {
        let html = ''
        axios.post(this.baseUrl + '/order/list', { currPage: 1, token: token }).then((res) => {
            let data = res.data.list
            data.forEach((v, i) => {
                // console.log(v);
                switch (v.orderStatus) {
                    case '00':
                        v.orderStatus = '已取消'
                        break;
                    case '01':
                        v.orderStatus = '已支付'
                        break;
                    case '02':
                        v.orderStatus = '待支付'
                        break;
                }
                if (v.carts.length > 1) {

                } else {
                    html += `<div class="items">
                <a href="./ddxx.html?oid=${v.orderId}">
                    <div class="top">
                        <img src="${v.carts[0].imgUrl}">
                        <div class="xinx">
                            <p>${v.carts[0].masterName}</p>
                            <div class="xinx-xx">
                                <span class="sp1">￥<span class="sp1-1">${v.carts[0].price/100}</span></span>
                                <span class="sp2">x<span class="sp2-1">${v.carts[0].buyNum}</span></span>
                            </div>
                        </div>
                    </div>
                    <div class="ma">
                        <div class="d1">共<span class="d1-sp">${v.carts[0].buyNum}</span>件商品&nbsp;实付</div>
                        <div class="d2">￥<span class="d2-sp">${v.totalMoney/100}</span></div>
                    </div>
                </a>
                <div class="fo">
                    <div class="left">订单状态：<span class="lf-sp">${v.orderStatus}</span></div>
                    <input type="button" value="重新购买">
                </div>
            </div>`
                }
            })
            document.querySelector('#ddxx').innerHTML = html
        })

    }
}

onload = () => {
    let token = localStorage.getItem('token')
    Home.renderOrder(token)
}